#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define maxsize 20
struct jiedian
{
	int date[maxsize];
	int length;
	int listsize;
}list;
void cha(struct jiedian * p,int i,int number)
{
	int k;
	for(k=p->length;k>=i;k--)
	{
		p->date[k]=p->date [k-1];
	}
	p->date[i-1]=number;
	p->length ++;
}
void dele(struct jiedian * p,int i)
{
	int k;
	for(k=i-1;k<p->length-1;k++)
	{
		p->date [k]=p->date [k+1];
	}
	p->length --;
}
void update(struct jiedian * p,int i,int number)
{
	p->date[i-1]=number;
}
void xianshi(struct jiedian * p,int i)
{
	if(i==0)
	{
		for(i=0;i<p->length;i++)
		{
			printf("%d\n",p->date[i]);
		}
	}
	else
	{
		printf("%d\n",p->date[i-1]);
	}
}
void main()
{
	char x;
	int i;
	int number;
	struct jiedian * p=&list;
	list.length =0;
	list.listsize =maxsize;
	do
	{
		scanf("%c",&x);
		switch(x)
		{
		case'i':
			{
				scanf("%d%d",&i,&number);
				cha(p,i,number);
				xianshi(p,0);
				break;
			}
		case'd':
			{
				scanf("%d",&i);
				dele(p,i);
				xianshi(p,0);
				break;
			}
		case'u':
			{
				scanf("%d%d",&i,&number);
				update(p,i,number);
				xianshi(p,0);
				break;
			}
		case'r':
			{
				scanf("%d",&i);
				xianshi(p,i);
				break;
			}
		case'q':
			{
				exit(0);
			}
		}
	}while(1);
}